package com.scrat.huzhenjie.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.scrat.huzhenjie.model.Test;
import com.scrat.huzhenjie.service.HuzhenjieService;

@Controller
@RequestMapping(value = "/")
public class BasicController {
	@Autowired
	private HuzhenjieService huzhenjieService;
	@RequestMapping(value = "/test")
	@ResponseBody
	public Test test() {
		return huzhenjieService.testBAESQL();
	}
	
	@RequestMapping(value = "/main")
	public String loadMain() {
		return "main";
	}
	
	@RequestMapping(value = "/error/{code}")
	@ResponseBody
	public String error(	@PathVariable("code") int code,
									@RequestParam(defaultValue = "") String msg){
		return "{\"error_code\":" + code + ",\"msg\":\"" + msg + "\"}";
	}
}
